home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10577 < prev    next >
Encoding:
Text File  |  1996-08-05  |  919 b   |  34 lines

  1. Path: ccshst05.cs.uoguelph.ca!ccshst01!thay
  2. From: thay@uoguelph.ca (Toby K Hay)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Getting date in UNIX
  5. Date: 18 Mar 1996 19:38:10 GMT
  6. Organization: University of Guelph
  7. Message-ID: <4ike32$c8n@ccshst05.cs.uoguelph.ca>
  8. References: <4ik447$bn7@raffles.technet.sg>
  9. NNTP-Posting-Host: ccshst01.cs.uoguelph.ca
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Leonard Sim (leonard@pacific.net.sg) wrote:
  13. : Can anyone please inform me how to obtain the date in UNIX C??
  14. : I just need the date in this format "dd/mm/yyyy". Thanks!!!
  15.  
  16. I just did this for the first time using an example from my Turbo C 
  17. reference by Herb Schildt.  (Will mentioning that name start another 
  18. long thread on his failings?)  
  19.  
  20. #include "time.h"
  21. #include "stdio.h"
  22. int main(void)
  23. {  struct tm *ptr;
  24.    time_t lt;
  25.  
  26.   lt = time(NULL);
  27.   ptr = localtime(<);
  28.   printf(asctime(ptr));
  29.   return 0;
  30. }
  31.  
  32. Toby Hay    thay@uoguelph.ca
  33.  
  34.